import { Navigate } from 'react-router-dom'
import { RouteObject } from '@/router/interface'
/** 首页 */
import HomePage from '@/apps/bug-manager/views/home/index'
/** 项目 */
import Project from '@/apps/bug-manager/views/project'
import ProjectDetails from '@/apps/bug-manager/views/project/ProjectDetails'
import ProjectList from '@/apps/bug-manager/views/project/ProjectList'
import AddProject from '@/apps/bug-manager/views/project/AddProject'
import ModuleList from '@/apps/bug-manager/views/project/ModuleList'
import AddModule from '@/apps/bug-manager/views/project/AddModule'
import ModuleDetails from '@/apps/bug-manager/views/project/ModuleDetails'
/** 组织 */
import OrganizationPage from '@/apps/bug-manager/views/organization'
import UserTree from '@/apps/bug-manager/views/organization/UserTree'
import CreateUser from '@/apps/bug-manager/views/organization/CreateUser'
/** 测试 */
import TestPage from '@/apps/bug-manager/views/test'
import CreateBug from '@/apps/bug-manager/views/test/CreateBug'
import ShowBugs from '@/apps/bug-manager/views/test/BugList'
import BugDetail from '@/apps/bug-manager/views/test/BugDetail'
/** 系统 */
import SystemConfig from '@/apps/bug-manager/views/system'
// 字典
import AddDictionary from '@/apps/bug-manager/views/system/dictionary/AddDictionary'
import DictionaryTable from '@/apps/bug-manager/views/system/dictionary/DictionaryTable'
// 数据库
import DatabaseList from '@/apps/bug-manager/views/system/database/DatabaseList'

// 404
import NotFound from '@/apps/all-in-one/NotFound'

const BugManagerRouter: RouteObject[] = [
	{
		path: '',
		element: <Navigate to='home' />
	},
  {
	  path: 'home',
		element: <HomePage />,
		meta: {
			requireAuth: true,
			title: 'bug-manager',
			key: 'bug-manager-home'
		}
	},
	{
		path: 'project',
		element: <Project />,
		meta: {
			requireAuth: true,
			title: 'bug-manager',
			key: 'bug-manager-project'
		},
		children: [
			{
				path: 'project-list',
				element: <ProjectList />,
				meta: {
					requireAuth: true,
					title: 'bug-manager',
					key: 'bug-manager-project-list'
				}
			},
			{
				path: 'module-list',
				element: <ModuleList />,
				meta: {
					requireAuth: true,
					title: 'bug-manager',
					key: 'bug-manager-module-list'
				}
			},
			{
				path: 'add-project',
				element: <AddProject />,
				meta: {
					requireAuth: true,
					title: 'bug-manager',
					key: 'bug-manager-add-project'
				}
			},
			{
				path: 'add-module',
				element: <AddModule />,
				meta: {
					requireAuth: true,
					title: 'bug-manager',
					key: 'bug-manager-add-module'
				}
			},
			{
				path: 'project-details',
				element: <ProjectDetails />,
				meta: {
					requireAuth: true,
					title: 'bug-manager',
					key: 'bug-manager-project-details'
				}
			},
			{
				path: 'module-details',
				element: <ModuleDetails />,
				meta: {
					requireAuth: true,
					title: 'bug-manager',
					key: 'bug-manager-module-details'
				}
			}
		]
	},
	{
	  path: 'organization',
		element: <OrganizationPage />,
		meta: {
			requireAuth: true,
			title: 'bug-manager',
			key: 'bug-manager-organization'
		},
		children: [
			{
				path: '',
				element: <UserTree />
			},
			{
				path: 'user-tree',
				element: <UserTree />
			},
			{
				path: 'create-user',
				element: <CreateUser />
			},
		]
	},
	{
	  path: 'test',
		element: <TestPage />,
		meta: {
			requireAuth: true,
			title: 'bug-manager',
			key: 'bug-manager-test'
		},
		children: [
			{
				path: '',
				element: <CreateBug />,
			},
			{
				path: 'create-bug',
				element: <CreateBug />,
			},
			{
				path: 'show-bugs',
				element: <ShowBugs />,
			},
			{
				path: 'bug-detail',
				element: <BugDetail />,
			}
		]
	},

	{
		path: 'system',
		element: <SystemConfig />,
		meta: {
			requireAuth: true,
			title: 'bug-manager',
			key: 'bug-manager-system'
		},
		children: [
		  // 字典配置
			{
				path: '',
				element: <AddDictionary />,
			},
			{
				path: 'dictionary/add-dictionary',
				element: <AddDictionary />,
			},
			{
				path: 'dictionary/dictionary-table',
				element: <DictionaryTable />,
			},
			// 数据库管理
			{
				path: 'database/database-list',
				element: <DatabaseList />,
			}
		]
	},
	{
		path: '*',
		element: <NotFound />,
	}
]
export default BugManagerRouter